/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package SingleLinkedList;

/**
 *
 * @author Administrator
 */
public class MySingleList implements ISingleList
{
    private SingleNode head;
    private SingleNode tail;
    private int size;

    public MySingleList()
    {
        head = null;
        tail = null;
        size = 0;
    }

    public MySingleList(Object o)
    {
        head = new SingleNode(o, null);
        tail = head;
        size = 1;
    }

    public SingleNode getHead()
    {
        return head;
    }

    public void setHead(SingleNode head)
    {
        this.head = head;
    }

    public int getSize()
    {
        return size;
    }

    public void setSize(int size)
    {
        this.size = size;
    }

    public SingleNode getTail()
    {
        return tail;
    }

    public void setTail(SingleNode tail)
    {
        this.tail = tail;
    }

    public boolean isEmpty()
    {
        return (size == 0);
    }

    public int size()
    {
        return size;
    }

    public void addElement(Object o)
    {
        SingleNode v = new SingleNode(o, null);
        if(isEmpty())
            head = v;
        else
            tail.setNext(v);
        tail = v;
        size++;
    }

}
